package cn.wit.test;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import org.junit.Test;

public class DemoListSort {

	

	@Test
	public void test1() {
		int[] a = { 1, 2, 3, 4, 5, 6, 7 };
		Arrays.sort(a);
		for (int i = 1; i < a.length; i++) {
			if ((a[i] ^ a[i - 1]) == 0) {
				System.out.println("有重复");
				break;
			}
		}
	

	}
	@Test
	public void test2() {
		int[] a= {2,2,1,1,3,0,3};
		
		int ret = 0;//余数

		//使用移位运算,把每一位对应加起来
		for(int i =0;i<32;i++) {
			int sum = 0;
			for(int j =0;j<a.length;j++) {
				sum+=(a[j]>>i)&1;
			}
			ret |=(sum%2)<<i;
		}
		
		System.out.println(ret);
	}
	
	//待解决
	@Test
	public void test3() {
		int[] a= {1,2,3,4,5,6,7,8,1};
		
		int ret = 0;//余数

		//使用移位运算,把每一位对应加起来
		for(int i =0;i<10;i++) {
			int sum = 0;
			for(int j =0;j<a.length;j++) {
				sum+=(a[j]>>i)&1;//这里是统计1出现的次数
			}
			System.out.print((sum%2)+" ");
//			if(sum!=0) {
//				sum=(sum%2)^1;
//			}
			sum = sum%2;
			ret |=((sum)<<i);
		
		}
		System.out.println();
		System.out.println(ret);
	}
	
	@Test
	public void test4() {
		int a =5;
		int b=1;
		System.out.println(a^b);
	}

}
